/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package iteracon;

import iteracon.generator.Range;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import iteracon.stack.EmptyStk;
import iteracon.stack.Stk;
import iteracon.tuple.Tuple;

/**
 *
 * @author martin
 */
public class test {
  public static void main(String [] args){
    long start,end;
    
    Object [] array = new Object[1000000];
    List arraylist = new ArrayList();
    List linkedlist = new LinkedList();
    
    Stk stack = EmptyStk.makeStk();
    
    System.out.print("fill array");
    start = System.nanoTime();
    for (int i=0;i<1000000;i++)
      array[i]=i;
    end = System.nanoTime();
    System.out.println(" : " + (end-start) + "tick");
    
    System.out.print("fill arraylist");
    start = System.nanoTime();
    for (int i=0;i<1000000;i++)
      arraylist.add(i);
    end = System.nanoTime();
    System.out.println(" : " + (end-start) + "tick");
    
    System.out.print("fill linkedlist");
    start = System.nanoTime();
    for (int i=0;i<1000000;i++)
      linkedlist.add(i);
    end = System.nanoTime();
    System.out.println(" : " + (end-start) + "tick");
    
    System.out.print("fill stk");
    start = System.nanoTime();
    for (int i=0;i<1000000;i++)
      stack = stack.push(i);
    end = System.nanoTime();
    System.out.println(" : " + (end-start) + "tick");
    
    Object tmp;
    
    System.out.print("iterate array");
    start = System.nanoTime();
    for (Object i : array)
      tmp = i;
    end = System.nanoTime();
    System.out.println(" : " + (end-start) + "tick");
    
    System.out.print("iterate arraylist");
    start = System.nanoTime();
    for (Object i : arraylist)
      tmp = i;
    end = System.nanoTime();
    System.out.println(" : " + (end-start) + "tick");
    
    System.out.print("iterate linkedlist");
    start = System.nanoTime();
    for (Object i : linkedlist)
      tmp = i;
    end = System.nanoTime();
    System.out.println(" : " + (end-start) + "tick");
    
    System.out.print("iterate stack");
    start = System.nanoTime();
    for (Object i : stack)
      tmp = i;
    end = System.nanoTime();
    System.out.println(" : " + (end-start) + "tick");
    
    System.out.print("iterate tuple");
    List tuple = Tuple.make(array);
    start = System.nanoTime();
    for (Object i : tuple)
      tmp = i;
    end = System.nanoTime();
    System.out.println(" : " + (end-start) + "tick");
    
    System.out.print("iterate range");
    List<Integer> range = Range.fromZero(1000000);
    start = System.nanoTime();
    for (Object i : range)
      tmp = i;
    end = System.nanoTime();
    System.out.println(" : " + (end-start) + "tick");
    
    System.out.print("iterate range step");
    List<Integer> rangestep = Range.fromToStep(0,1000000,1);
    start = System.nanoTime();
    for (Object i : rangestep)
      tmp = i;
    end = System.nanoTime();
    System.out.println(" : " + (end-start) + "tick");
  
/******************************************************************************/

    System.out.print("forloop array");
    start = System.nanoTime();
    for (int i=0;i<array.length;i++)
      tmp = array[i];
    end = System.nanoTime();
    System.out.println(" : " + (end-start) + "tick");
    
    System.out.print("forloop arraylist");
    start = System.nanoTime();
    for (int i=0;i<arraylist.size();i++)
      tmp = arraylist.get(i);
    end = System.nanoTime();
    System.out.println(" : " + (end-start) + "tick");
    
    System.out.println("dont forloop linkedlist");
//    start = System.nanoTime();
//    for (int i=0;i<linkedlist.size();i++)
//      tmp = linkedlist.get(i);
//    end = System.nanoTime();
//    System.out.println(" : " + (end-start) + "tick");
    
 
    System.out.println("dont forloop stack");
//    start = System.nanoTime();
//    for (int i=0;i<stack.size();i++)
//      tmp = stack.get(i);
//    end = System.nanoTime();
//    System.out.println(" : " + (end-start) + "tick");
    
    System.out.print("forloop tuple");
    start = System.nanoTime();
    for (int i=0;i<tuple.size();i++)
      tmp = tuple.get(i);
    end = System.nanoTime();
    System.out.println(" : " + (end-start) + "tick");
    
    System.out.print("forloop range");
    start = System.nanoTime();
    for (int i=0;i<range.size();i++)
      tmp = range.get(i);
    end = System.nanoTime();
    System.out.println(" : " + (end-start) + "tick");
  }
}
